<script setup lang="ts">
import { watch } from 'vue';
import { ref } from 'vue';

let text=ref("")
const jinci=["你","我","他"]

let isRed=ref(false)

watch(
()=>text.value,
(nv,ov)=>{
    jinci.forEach(s=>{
        if(nv.includes(s)){
            isRed.value=true
            // let hefa_text=nv.substring(0,nv.length-1);
            // text.value=hefa_text;
            // alert("您的回复中包含了禁词");
        }
    })
})
</script>
<template>
<input type="text" placeholder="请输入，不能有'我'" v-model="text"
class="bg_yellow" :class="{bg_red:isRed}">
</input>
</template>

<style scoped>
.bg_yellow{
    background-color: yellow;
}
.bg_red{
    background-color: red;
}
</style>